<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html xmlns:yui="http://yuilibrary.com/rdf/1.0/yui.rdf#">
<head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
	<title>API: CWN2   json.js  (YUI Library)</title>

	<link rel="stylesheet" type="text/css" href="assets/reset-fonts-grids-min.css?stamp=1308058435.87" />
	<link rel="stylesheet" type="text/css" href="assets/api.css?stamp=1308058435.87" />

    <script type="text/javascript" src="assets/api-js?stamp=1308058435.87"></script>
    <script type="text/javascript" src="assets/ac-js?stamp=1308058435.87"></script>
</head>

<body id="yahoo-com">

<div id="doc3" class="yui-t2">
	<div id="hd">
        <h1><a href="/CartoWebNet2/lib/Cwn2/" title="CartoWebNet2 Javascript Library">CartoWebNet2 Javascript Library</a></h1>
        <h3>CWN2&nbsp; <span class="subtitle">1.0.0</span></h3>
        <a href="./index.html" title="CartoWebNet2 Javascript Library">CartoWebNet2 Javascript Library</a> 
            &gt; <a href="./module_cwn2.html" title="CWN2">CWN2</a>
                
                 &gt; json.js (source view) 
        <form onsubmit="return false">
            <div id="propertysearch">
                Search: <input autocomplete="off" id="searchinput" />
                <div id="searchresults">
                    &nbsp;
                </div>
            </div>
        </form>
	</div>

	<div id="bd">
		<div id="yui-main">
			<div class="yui-b">
            <form action="#" name="yui-classopts-form" method="get" id="yui-classopts-form">
                <fieldset>
                    <legend>Filters</legend>
                <span class="classopts"><input type="checkbox" name="show_private" id="show_private" /> <label for="show_private">Show Private</label></span>
                <span class="classopts"><input type="checkbox" name="show_protected" id="show_protected" /> <label for="show_protected">Show Protected</label></span>
                <span class="classopts"><input type="checkbox" name="show_deprecated" id="show_deprecated" /> <label for="show_deprecated">Show Deprecated</label></span>
                </fieldset>
            </form>

                    <div id="srcout">
                        <style>
                            #doc3 .classopts { display:none; }
                        </style>
<div class="highlight"><pre><span class="c1">//#include &lt;base.js&gt;</span>

<span class="cm">/**</span>
<span class="cm">* </span>
<span class="cm">* Classe gestione json - Contiene metodi per caricare json ecc...</span>
<span class="cm">* </span>
<span class="cm">* @namespace CWN2</span>
<span class="cm">* @class json</span>
<span class="cm">* </span>
<span class="cm">*/</span>

<span class="nx">CWN2</span><span class="p">.</span><span class="nx">json</span> <span class="o">=</span> <span class="p">{</span>
	
<span class="cm">/**</span>
<span class="cm">* </span>
<span class="cm">* Funzione per caricare un oggetto json remoto in maniera sincrona o asincrona</span>
<span class="cm">* </span>
<span class="cm">* @method load</span>
<span class="cm">* </span>
<span class="cm">* @param {String} url Url del file o del servizio</span>
<span class="cm">* @param {bool} sync Flag che indica se effettuare una richiesta sincrona</span>
<span class="cm">* @return {obj} Oggetto Javascript </span>
<span class="cm">* </span>
<span class="cm">*/</span>

	<span class="nx">load</span><span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">url</span><span class="p">,</span><span class="nx">sync</span><span class="p">)</span> <span class="p">{</span>
	  <span class="k">if</span> <span class="p">(</span><span class="nx">CWN2</span><span class="p">.</span><span class="nx">base</span><span class="p">.</span><span class="nx">DEBUG</span><span class="p">)</span> <span class="p">{</span>
		<span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s1">&#39;CWN2.json.load&#39;</span><span class="p">);</span>
	  <span class="p">}</span>

	  <span class="kd">var</span> <span class="nx">request</span><span class="p">;</span>
	  <span class="c1">// richiesta sincrona</span>
	  <span class="k">if</span> <span class="p">(</span><span class="nx">sync</span><span class="p">)</span> <span class="p">{</span>
		  <span class="k">if</span> <span class="p">(</span><span class="nb">window</span><span class="p">.</span><span class="nx">XMLHttpRequest</span><span class="p">)</span> <span class="p">{</span>              
		    <span class="nx">request</span> <span class="o">=</span><span class="k">new</span> <span class="nx">XMLHttpRequest</span><span class="p">();</span>              
		  <span class="p">}</span> <span class="k">else</span> <span class="p">{</span>                                  
		    <span class="nx">request</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">ActiveXObject</span><span class="p">(</span><span class="s2">&quot;Microsoft.XMLHTTP&quot;</span><span class="p">);</span>
		  <span class="p">}</span>
		  <span class="k">if</span> <span class="p">(</span><span class="nx">request</span><span class="p">)</span> <span class="p">{</span>
		     <span class="nx">request</span><span class="p">.</span><span class="nx">open</span><span class="p">(</span><span class="s2">&quot;GET&quot;</span><span class="p">,</span> <span class="nx">url</span><span class="p">,</span> <span class="kc">false</span><span class="p">);</span>                             
		     <span class="nx">request</span><span class="p">.</span><span class="nx">send</span><span class="p">(</span><span class="kc">null</span><span class="p">);</span>
			<span class="k">return</span> <span class="nx">JSON</span><span class="p">.</span><span class="nx">parse</span><span class="p">(</span><span class="nx">request</span><span class="p">.</span><span class="nx">responseText</span><span class="p">);</span>
		  <span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
		     <span class="k">return</span> <span class="kc">false</span><span class="p">;</span>
		  <span class="p">}</span>
	  <span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
	  	<span class="k">this</span><span class="p">.</span><span class="nx">loadAsync</span><span class="p">(</span><span class="nx">url</span><span class="p">);</span>
	  <span class="p">}</span>
	<span class="p">},</span>
	<span class="cm">/**</span>
<span class="cm">	* </span>
<span class="cm">	* Funzione per caricare un oggetto json remoto in maniera asincrona</span>
<span class="cm">	* </span>
<span class="cm">	* @method loadAsync</span>
<span class="cm">	* </span>
<span class="cm">	* @param {String} url Url del file o del servizio</span>
<span class="cm">	* @param {bool} sync Flag che indica se effettuare una richiesta sincrona </span>
<span class="cm">	* @return {obj} Oggetto Javascript </span>
<span class="cm">	* </span>
<span class="cm">	*/</span>
	<span class="nx">loadAsync</span><span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">url</span><span class="p">){</span>
	  <span class="c1">//TODO: da rivedere</span>
	  <span class="c1">// richiesta asincrona</span>
		<span class="kd">function</span> <span class="nx">handler</span><span class="p">(</span><span class="nx">request</span><span class="p">)</span> <span class="p">{</span>
			<span class="k">return</span> <span class="nx">JSON</span><span class="p">.</span><span class="nx">parse</span><span class="p">(</span><span class="nx">request</span><span class="p">.</span><span class="nx">responseText</span><span class="p">);</span>
		<span class="p">}</span>
		<span class="nx">request</span> <span class="o">=</span> <span class="nx">OpenLayers</span><span class="p">.</span><span class="nx">Request</span><span class="p">.</span><span class="nx">GET</span><span class="p">({</span>
	    	<span class="s1">&#39;url&#39;</span><span class="o">:</span> <span class="nx">url</span><span class="p">,</span>
	    	<span class="s1">&#39;callback&#39;</span><span class="o">:</span> <span class="nx">handler</span>
		<span class="p">});</span>	
	<span class="p">}</span>
	
	
<span class="p">};</span>
</pre></div>
                    </div>
			</div>
		</div>
		<div class="yui-b">
            <div class="nav">

                    <div id="moduleList" class="module">
                        <h4>Modules</h4>
                        <ul class="content">
                                <li class="selected"><a href="module_CWN2.html" title="CWN2">CWN2</a></li>
                        </ul>
                    </div>

                    <div id="classList" class="module">
                        <h4>Classes</h4>
                        <ul class="content">
                                <li class=""><a href="CWN2.configuration.html" title="CWN2.configuration">CWN2.configuration</a></li>
                                <li class=""><a href="CWN2.event.html" title="CWN2.event">CWN2.event</a></li>
                                <li class=""><a href="CWN2.json.html" title="CWN2.json">CWN2.json</a></li>
                                <li class=""><a href="CWN2.layerFactory.html" title="CWN2.layerFactory">CWN2.layerFactory</a></li>
                                <li class=""><a href="CWN2.Map.html" title="CWN2.Map">CWN2.Map</a></li>
                        </ul>
                    </div>

                    <div id="fileList" class="module">
                        <h4>Files</h4>
                        <ul class="content">        
                                <li class=""><a href="base.js.html" title="base.js">base.js</a></li>
                                <li class=""><a href="configuration.js.html" title="configuration.js">configuration.js</a></li>
                                <li class=""><a href="event.js.html" title="event.js">event.js</a></li>
                                <li class="selected"><a href="json.js.html" title="json.js">json.js</a></li>
                                <li class=""><a href="layerFactory.js.html" title="layerFactory.js">layerFactory.js</a></li>
                                <li class=""><a href="Map.js.html" title="Map.js">Map.js</a></li>
                                <li class=""><a href="openlayersExt.js.html" title="openlayersExt.js">openlayersExt.js</a></li>
                        </ul>
                    </div>





            </div>
		</div>
	</div>
	<div id="ft">
        <hr />
        Copyright &copy; 2011 Yahoo! Inc. All rights reserved.
	</div>
</div>
<script type="text/javascript">
    ALL_YUI_PROPS = [{"url": "CWN2.Map.html#method_activateSelectFeatureControl", "access": "", "host": "CWN2.Map", "type": "method", "name": "activateSelectFeatureControl"}, {"url": "CWN2.configuration.html#property_buttons", "access": "", "host": "CWN2.configuration", "type": "property", "name": "buttons"}, {"url": "CWN2.configuration.html#property_controls", "access": "", "host": "CWN2.configuration", "type": "property", "name": "controls"}, {"url": "CWN2.layerFactory.html#method_createLayer", "access": "", "host": "CWN2.layerFactory", "type": "method", "name": "createLayer"}, {"url": "CWN2.configuration.html#method_getLayerConfigByName", "access": "", "host": "CWN2.configuration", "type": "method", "name": "getLayerConfigByName"}, {"url": "CWN2.configuration.html#property_layers", "access": "", "host": "CWN2.configuration", "type": "property", "name": "layers"}, {"url": "CWN2.configuration.html#property_layout", "access": "", "host": "CWN2.configuration", "type": "property", "name": "layout"}, {"url": "CWN2.configuration.html#method_load", "access": "", "host": "CWN2.configuration", "type": "method", "name": "load"}, {"url": "CWN2.json.html#method_load", "access": "", "host": "CWN2.json", "type": "method", "name": "load"}, {"url": "CWN2.json.html#method_loadAsync", "access": "", "host": "CWN2.json", "type": "method", "name": "loadAsync"}, {"url": "CWN2.Map.html#method_loadConfig", "access": "", "host": "CWN2.Map", "type": "method", "name": "loadConfig"}, {"url": "CWN2.Map.html#method_loadLayer", "access": "", "host": "CWN2.Map", "type": "method", "name": "loadLayer"}, {"url": "CWN2.Map.html#method_loadLayers", "access": "", "host": "CWN2.Map", "type": "method", "name": "loadLayers"}, {"url": "CWN2.configuration.html#property_mapOptions", "access": "", "host": "CWN2.configuration", "type": "property", "name": "mapOptions"}, {"url": "CWN2.configuration.html#property_name", "access": "", "host": "CWN2.configuration", "type": "property", "name": "name"}, {"url": "CWN2.event.html#method_onFeatureSelect", "access": "", "host": "CWN2.event", "type": "method", "name": "onFeatureSelect"}, {"url": "CWN2.event.html#method_onFeatureUnselect", "access": "", "host": "CWN2.event", "type": "method", "name": "onFeatureUnselect"}];
</script>
</body>
</html>
